package bit2;
class Shape {
    public void draw() {

    }
}

class Cycle extends Shape{
    @Override
    public void draw() {
        System.out.println("画一个矩形●");//ctr+o
    }
}

class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("画一个方片♦");
    }
}

class Flower extends Shape {
    @Override
    public void draw() {
        System.out.println("画一朵小红花❀");
    }
}
public class bitMain8 {
    public static void drawShapes() {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();

        //目的：分别画 圆 矩形 圆 矩形 花
        String[] shapes = {"cycle", "rect", "cycle", "rect", "flower"};


        for (String shape : shapes) {
            if (shape.equals("cycle")) {
                cycle.draw();
            } else if (shape.equals("rect")) {
                rect.draw();
            } else if (shape.equals("flower")) {
                flower.draw();
            }
        }
    }

    public static void drawShapes2() {
        // 我们创建了一个 Shape 对象的数组.
        Shape[] shapes = {new Cycle(), new Rect(), new Cycle(),
                new Rect(), new Flower()};
        for (Shape shape : shapes) {
            shape.draw();
        }
    }

    public static void main(String[] args) {
        drawShapes2();
    }

    public static void drawMap(Shape shape) {
        shape.draw();
    }

    public static void main2(String[] args) {
        drawMap(new Cycle());

        drawMap(new Rect());

        drawMap(new Flower());
    }

    public static void main1(String[] args) {
        Cycle cycle = new Cycle();
        drawMap(cycle);

        Rect rect = new Rect();
        drawMap(rect);

        Flower flower = new Flower();
        drawMap(flower);
    }
}
